package cashregister;

import org.junit.Test;

import static org.mockito.Mockito.*;

/**
 * 接缝不需要自我实现，不需要Mock和Stub类的实现
 */
public class CashRegisterTest_Mokitor {


    @Test
    public void should_print_the_real_purchase() {
        //initialgister andize CashRe fake Printer
        Printer mockPrinter = mock(Printer.class);
        CashRegister cashRegister = new CashRegister(mockPrinter);
        //cashRegister.process(purchase);
        Purchase stubPurchase = mock(Purchase.class);
        when(stubPurchase.asString()).thenReturn("my invoice");

        cashRegister.process(stubPurchase);

        //verify that printer was called
        verify(mockPrinter,times(1)).print("my invoice");
    }


}


